//
//  LiveShowDataIntroductView.m
//  
//
//  Created by DK on 17/1/22.
//  Copyright © 2017年 ChunYu. All rights reserved.
//

#import "LiveShowDataIntroductView.h"

@implementation LiveShowDataIntroductView{
    UIButton *_foldBtn;
    BOOL _fold;
    UILabel *_introLabel;
}

- (instancetype)initWithTitle:(NSString *)title IntroductText:(NSString *)text Fold:(BOOL)fold{
    
    if (self = [super init]) {
    
//        self.width = viewWidth();
        _fold = fold;
        
        UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 0)];
        titleLabel.text = title;
        titleLabel.font = [UIFont boldSystemFontOfSize:15];
        titleLabel.textColor = [UIColor redColor];
        [self addSubview:titleLabel];
        
        _foldBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        NSString *btnImageName = fold ? @"":@"";
        [_foldBtn setImage:[UIImage imageNamed:btnImageName] forState:UIControlStateNormal];
        [_foldBtn addTarget:self action:@selector(foldText) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_foldBtn];
        
        _introLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        _introLabel.text = text;
        _introLabel.textColor = [UIColor blueColor];
        _introLabel.font = [UIFont systemFontOfSize:13];
        _introLabel.numberOfLines = fold ? 3:0;
        [_introLabel sizeToFit];
        [self addSubview:_introLabel];
        
//        self.height = _introLabel.bottom + 10;
        
    }
    return self;
}


- (void)foldText{
    
    _fold = !_fold;
    
    NSString *btnImageName = _fold ? @"":@"";
    [_foldBtn setImage:[UIImage imageNamed:btnImageName] forState:UIControlStateNormal];
    _introLabel.numberOfLines = _fold ? 3:0;
    [_introLabel sizeToFit];
//  self.height = _introLabel.bottom + 10;

}

@end
